﻿using DotNEToolkit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinformToolkit.Binding
{
    /// <summary>
    /// 实现一个Winform的绑定机制
    /// </summary>
    public class BindingManager : SingletonObject<BindingManager>
    {
        private object mapLock;

        /// <summary>
        /// source -> BindingContext
        /// </summary>
        private Dictionary<object, BindingContext> bindingMap;

        public BindingManager()
        {
            this.mapLock = new object();
            this.bindingMap = new Dictionary<object, BindingContext>();
        }

        /// <summary>
        /// 增加一个绑定
        /// </summary>
        /// <param name="target">要绑定到的控件</param>
        /// <param name="property"></param>
        /// <param name="source">数据源</param>
        /// <param name="path"></param>
        public void AddBinding(Control target, string property, object source, string path)
        {
            BindingContext context = new BindingContext() 
            {
                Target = target,
                Property = property,
                Source = source,
                Path = path
            };

            lock (this.mapLock)
            {
            }
        }
    }
}
